/* ========================================================================= */
/* ------------------------------------------------------------------------- */
/*!		
  \file			findwidget.h
  \date			Dec 2012
  \author		TNick

  \brief		Contains the definition for FindWidget class


*//*


 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 Please read COPYING and README files in root folder
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*/
/* ------------------------------------------------------------------------- */
/* ========================================================================= */
#ifndef __FINDWIDGET_INC__
#define __FINDWIDGET_INC__
//
//
//
//
/*  INCLUDES    ------------------------------------------------------------ */

#include	<memtrack.h>
#include	<QWidget>
#include	<ui_findwidget.h>

/*  INCLUDES    ============================================================ */
//
//
//
//
/*  CLASS    --------------------------------------------------------------- */

/**
*	@brief	
*/
class FindWidget	: public QWidget, public MemTrack			{
	Q_OBJECT
	BBM_TRACK( FindWidget );
	
	//
	//
	//
	//
	/*  DEFINITIONS    ----------------------------------------------------- */

	union		impl_dep_val	{
		qint64			i_;
		double			d_;
		void *			p_;
	};

	/*  DEFINITIONS    ===================================================== */
	//
	//
	//
	//
	/*  DATA    ------------------------------------------------------------ */

private:

	/**
	*	@brief
	*/
	Ui::FindWidget				ui_;



	/**
	*	@brief	holds the implementation dependent value of the current find
	*/
	impl_dep_val				val_;


	/*  DATA    ============================================================ */
	//
	//
	//
	//
	/*  FUNCTIONS    ------------------------------------------------------- */

public:


	/**
	*	@brief	constructor;
	*/
	FindWidget			(
			const QString &				s_init = QString(),
			bool						with_adv = false,
			bool						with_replace = true,
			QWidget *					parent = NULL
			);


	/**
	*	@brief	destructor;
	*/
	virtual				~FindWidget		( void );

	
	/**
	*	@brief	set internal marker (implementation-defined)
	*/
	inline void			setMarker		( void * p )
	{ val_.p_ = p; }


	/**
	*	@brief	set internal marker (implementation-defined)
	*/
	inline void			setMarker		( double d )
	{ val_.d_ = d; }


	/**
	*	@brief	set internal marker (implementation-defined)
	*/
	inline void			setMarker		( qint64 i )
	{ val_.i_ = i; }


	/**
	*	@brief	get internal marker (implementation-defined)
	*/
	inline void *		markerPtr		( void ) const
	{ return val_.p_; }


	/**
	*	@brief	get internal marker (implementation-defined)
	*/
	inline double		markerDbl		( void ) const
	{ return val_.d_; }


	/**
	*	@brief	get internal marker (implementation-defined)
	*/
	inline qint64		markerInt		( void ) const
	{ return val_.i_; }


	/**
	*	@brief	change the text to find
	*/
	void				setFindText		( const QString & s_text );


private slots:

	void				findNext		( void );
	void				findPrev		( void );
	void				replaceAll		( void );
	void				replaceNext		( void );
	void				replaceOne		( void );


signals:


	/**
	*	@brief	the widget should be closed
	*/
	void				closeReq		( void );


	/**
	*	@brief	the implementation should show the advanced find dialog
	*/
	void				showAdvanced	( void );


	/**
	*	@brief	the implementation should find the text
	*/
	void				findNext		( const QString & s_text );


	/**
	*	@brief	the implementation should find the text
	*/
	void				findPrev		( const QString & s_text );


	/**
	*	@brief	the implementation should replace all occurances
	*/
	void				replaceAll		( const QString & s_find, const QString & s_repl );


	/**
	*	@brief	the implementation should replace first occurance
	*/
	void				replaceNext		( const QString & s_find, const QString & s_repl );


	/**
	*	@brief	the implementation should replace current occurance, if any
	*/
	void				replaceOne		( const QString & s_find, const QString & s_repl );



	/*  FUNCTIONS    ======================================================= */
	//
	//
	//
	//

};	/*	class FindWidget	*/

/*  CLASS    =============================================================== */
//
//
//
//
#endif // __FINDWIDGET_INC__
/* ------------------------------------------------------------------------- */
/* ========================================================================= */
